﻿using MediatR;
using MyMES.Domain.W.Liststructure;
using MyMES.Error;
using MyMES.Infrastructure.Interface;
using MyMES.Read.API.Application.Commends.W.realize;

namespace MyMES.Read.API.Application.CommendHandlers.W.realize
{
    public class GetSalesordersheetCommandHanders : IRequestHandler<GetSalesordersheetCommands, APIResult<List<Salesordersheet>>>
    {
        private readonly IBaseRepository<Salesordersheet> _repository;

        public GetSalesordersheetCommandHanders(IBaseRepository<Salesordersheet> repository)
        {
            _repository = repository;
        }

        /// <summary>
        /// 显示销售订单信息
        /// </summary>
        /// <param name="request">销售订单</param>
        /// <param name="cancellationToken">2025年4月14日12:00:17</param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<APIResult<List<Salesordersheet>>> Handle(GetSalesordersheetCommands request, CancellationToken cancellationToken)
        {
            APIResult<List<Salesordersheet>> result = new APIResult<List<Salesordersheet>>();
            result.Code=APIEnum.查询成功;
            result.Msg = "显示成功";
            var sql = "select * from Salesordersheet";
            var list = await _repository.SelectAsync(sql);
            result.data = list;
            return result;
        }
    }
}
